14. Object Literal Notation

Object Literal Notation

INSTRUCTOR NOTE:

JavaScript objects behave a lot like Python dictionaries, but there are some differences we'll see later. For a detailed comparison, see this StackOverflow thread.


Though JavaScript has no classes, you can mimic many of the characteristics with its functions. You'll learn more about functions in Lesson 3 so consider this a bit of a preview.

function Car() {}
/*
var Car = function() {}
*/
var car1 = new Car();

The new keyword allows us to create a new instance of an Object. Remember that functions are objects. In the code above, you can think of the function Car as a JavaScript version of a Python class definition.

Follow your instructors!

@cwpittman

+jameswilliams